import socket
# 创建 socket 对象
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

# 获取本地主机名
host = '127.0.0.1'#socket.gethostname()

# 设置端口号
# = 12346
port = 8899
# 连接服务，指定主机和端口
s.connect((host, port))
msg_to_send = 'POST /socket_get HTTP/1.1\r\n'+'Host:127.0.0.1\r\nconnection: close\r\n\r\n'
s.send(msg_to_send.encode('utf-8'))
# 接收小于 1024 字节的数据

msg = s.recv(1024)
while msg:
    print(msg.decode('utf-8'))
    msg = s.recv(1024)
s.close()
